package com.ithzl.capacity.service.impl;

import com.ithzl.capacity.mapper.EntryFormMapper;
import com.ithzl.capacity.pojo.User;
import com.ithzl.capacity.pojo.dto.ReviewPageDTO;
import com.ithzl.capacity.pojo.dto.WorksBriefDTO;
import com.ithzl.capacity.service.ReviewService;
import com.ithzl.capacity.service.UserService;
import jakarta.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ReviewServiceImpl implements ReviewService {

    @Autowired
    EntryFormMapper entryFormMapper;
    @Override
    public List<WorksBriefDTO> selectWorksBrief(ReviewPageDTO reviewPageDTO) {
        List<WorksBriefDTO> worksBriefDTOList=entryFormMapper.selectEntryFormBrief(reviewPageDTO);
        return worksBriefDTOList;
    }

    @Override
    public void review(int entryFormId, String opinion, double score, HttpSession session) {
        User user =(User) session.getAttribute("user");
        int userId= user.getId();
        entryFormMapper.instOpinion(entryFormId,opinion,userId);
        entryFormMapper.updateScore(entryFormId,score);
    }
}
